/**
 *author:yuanchunci
 * 2017-6-14
 *Login.java
 */
package com.ycc.study.controller;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ycc.study.service.PersonService;

/**
 * @author yuanchunci
 *2017-6-14
 */
@Controller
@RequestMapping(value="login")
public class Login extends HttpServlet {
	@Resource
	private  PersonService personService;
    @RequestMapping(value="login")
	public String login(Model  model){
    	model.addAttribute("data", personService.getAllPerson());
        return "/login/login";
	}
    @RequestMapping(value="success",method=RequestMethod.POST)
    public String success(HttpServletRequest request,HttpServletResponse response,Model  model) throws IOException{
    	String redirect="redirect:login.html";
    	List ls=personService.getOnePerson(request);
    	if(ls != null && ls.size()>0){
    		redirect="redirect:file.html";
    	}
		return redirect;
    	   
	}
    @RequestMapping(value="file")
	public String file(Model  model){
        return "/file/success";
	}
}
